<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>电机型号名称：</p>
                                <input type="text" name="motorTypeName"/>
                            </li>
                            <li>
                                <p>电机型号编号：</p>
                                <input type="text" name="motorTypeNumber"/>
                            </li>
                            <li>
                                <p>电机种类：</p>
                                <select name="motorVariety">
                                    <option value="">所有</option>
                                    <option value="直流">直流</option>
                                    <option value="异步">异步</option>
                                    <option value="永磁同步">永磁同步</option>
                                    <option value="开关磁阻">开关磁阻</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:type:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:type:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:type:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:type:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
                <a class="btn btn-warning" onclick="ceshi()" shiro:hasPermission="system:type:export">
                    <i class="fa fa-download"></i> 测试
                </a>
                <a class="btn btn-primary single disabled"  data-toggle="modal" data-target="#myModal" shiro:hasPermission="system:type:edit">
                    <i class="fa fa-edit"></i> 激活
                </a>
            </div>


            <!-- Modal -->
            <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                <div class="modal-dialog" role="document">
                    <div class="modal-content" style="width: 1200px;height: 650px;">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">Modal title</h4>
                        </div>
                        <div class="modal-body">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">驱动电机冷却方式：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="motorCooling" class="form-control" placeholder="请输入文本">
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">额定电压：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="nominalVoltage" class="form-control" placeholder="请输入文本">V
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">额定电流：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="nominalElectricity" class="form-control" placeholder="请输入文本">A
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">额定功率：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="nominalPower" class="form-control" placeholder="请输入文本">kW
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">峰值功率：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="peakPower" class="form-control" placeholder="请输入文本">kW
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">有效比功率：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="specificPower" class="form-control" placeholder="请输入文本">kw/kg
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">额定功率转速：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="revolvingSpeed" class="form-control" placeholder="请输入文本">r/min
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">驱动电机最高转速：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="maxRevolving" class="form-control" placeholder="请输入文本">r/min
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">驱动电机峰值转矩：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled style="border:none;" name="peakTorque" class="form-control" placeholder="请输入文本">kg
                                    </div>
                                </div>
                                <br>
                                <div class="form-group">
                                    <label class="col-sm-3 control-label">驱动电机最大输出转矩：</label>
                                    <div class="col-sm-9">
                                        <input type="text" disabled  style="border:none;"name="maxTorque" class="form-control" placeholder="请输入文本">Nm
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript" type="text/javascript">
        var editFlag = [[${@permission.hasPermi('system:type:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:type:remove')}]];
        var prefix = ctx + "system/zjhmotortype";

        function toFind(id){
            $.ajax({
                url:prefix + "/toFind",
                type:"get",
                data:{id:id},
                datatype:"json",
                success:function (data) {
                    console.log(data);
                    $("[name = 'motorCooling']").val(data.motorCooling);
                    $("[name = 'nominalVoltage']").val(data.nominalVoltage);
                    $("[name = 'nominalElectricity']").val(data.nominalElectricity);
                    $("[name = 'nominalPower']").val(data.nominalPower);
                    $("[name = 'peakPower']").val(data.peakPower);
                    $("[name = 'specificPower']").val(data.specificPower);
                    $("[name = 'revolvingSpeed']").val(data.revolvingSpeed);
                    $("[name = 'maxRevolving']").val(data.maxRevolving);
                    $("[name = 'peakTorque']").val(data.peakTorque);
                    $("[name = 'maxTorque']").val(data.maxTorque);
                }
            })
        }

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id',
                    title : '驱动电机ID主键',
                    visible: false
                },
                {
                    field : 'motorTypeName',
                    title : '电机型号名称',
                },
                {
                    field : 'motorTypeNumber',
                    title : '电机型号编号'
                },
                {
                    field : 'motorVariety',
                    title : '电机种类'
                },
                {
                    field : 'motorBrandName',
                    title : '电机品牌名称'
                },
                {
                    title: '驱动电机基本信息',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a  data-toggle="modal" data-target="#myModal"  onclick="toFind(\'' + row.id + '\')"></i>查看详细信息</a> ');
                        return actions.join('');
                    }
                },
                {
                    field : 'producerName',
                    title : '生产厂商名称'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>
